Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

catenary-curve

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

catenary-curve

Calculate the perfect catenary between two points

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-15.26%
Maintainers
1
Weekly downloads
 
Created
Source

Catenary Curve - Calculate the ideal catenary between two points

Given two points and a length, this library will calculate and draw the catenary between two points, the "correct" way, so that it behaves natural (technically).

How to use

import { Catenary, Point } from 'catenary-curve'

// This is optional, you can also use a simple { x: 200, y: 300 } object.
let p1 = new Point(200, 300)
let p2 = new Point(250, 400)

let chain = new Catenary({
  segments: 50,
  iterationLimit: 100
})

const context = canvas.getContext('2d')

// The drawToCanvas function will only call the actual draw function (moveTo,
// lineTo, quadraticCurveTo), so you have to call beginPath() and stroke()
// yourself.
context.beginPath()
context.lineWidth = 1
context.strokeStyle = 'black'
chain.drawToCanvas(context, p1, p2, 500)
context.stroke()

Acknowledgement

The basis of this library is an ActionScript by poiasd, originally released on wonderfl.net, archived and preserved at http://wa.zozuar.org/code.php?c=8Bnl.

Unfortunately I wasn't able to find out who the original author was and ask them if and how they want to be mentioned/linked.

Keywords

FAQs

Package last updated on 29 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc